package com.neuedu.learn;


/**
 * 数组
 */
public class DemoArray2 {




    public static void main(String[] args) {

//        String names[] = {
//                "张飞","刘备"
//        };
        //names[0]  = "张飞"
        //names[1]  = "刘备"

//        多维数组的定义
//        String names[] = new String[32];
        //
        String names1[][]= new String[3][32];
        System.out.println(names1);
        System.out.println("names1[0] = " + names1[0]);



        String names2[][]= new String[3][];
        System.out.println(names2);
        names2[0] = new String[10];
        names2[1] = new String[20];
        names2[2]  =  new String[15];

        System.out.println("names2[0] = " + names2[0]);

        //names[0] =  String[0]?

        //使用常量 直接初始化  多为数组
        String names3[][] = {
                //i = 0
                // names3[0] = {  "1班a","1班b","1班c","1班d"   }
                {
                        "1班a","1班b","1班c","1班d"
                },
                {
                        "2班a","2班b","2班c"
                },
                {
                        "3班a","3班b","3班c"
                }
        };

        //多为数组的遍历
        for (int i = 0; i < names3.length; i++) {
            String[] nameItems = names3[i];
            //nameItems = names3[0] = {  "1班a","1班b","1班c","1班d"   }
            for (int j = 0; j < nameItems.length; j++) {
//                System.out.println("nameItems[j] = " + nameItems[j]);
                System.out.print(" names3["+i+"]["+j+"] = " + names3[i][j]+"\t");
            }
            System.out.println();
//            System.out.println("names3[i] = " + names3[i]);
        }

    }

}
